package com.tnr.scgcxx.dao.safty;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.dq.base.page.PageParam;

import com.tnr.scgcxx.dto.UserDto;
import com.tnr.scgcxx.model.User;

public interface UserDao {
	
	@Select("select u_id,u_name from sys_user where u_id=#{u_id} and u_pwd=#{u_pwd}")
	User findUserByUidAndPwd(UserDto userDto);
    
	@Select("select u_id,u_name,u_status from sys_user")
	public List<User> findAllUsers();
	
	//@Select("select u_id,u_name,u_remark,u_status from sys_user")
	public List<User> findUsersPage(PageParam pageParam);

	@Insert("insert into sys_user(u_id,u_name,u_pwd,u_status) values(#{u_id},#{u_name},'000000',#{u_status})")
	public int insertUser(UserDto dto);
	
	public int updateUser(UserDto dto);
	
	@Select("select u_id,u_name,u_status from sys_user where u_id=#{u_id}")
	public User findUserbyId(String u_id);

	public int deleteUserByIds(String... u_ids);

	public int updateUserStatusByIds(@Param("status") String status, @Param("u_ids") Integer[] u_ids);

	@Select("select ur.ro_id from sys_ur ur join sys_role ro on ro.ro_id=ur.ro_id where ur.u_id=#{u_id} and ro.ro_status='55'")
	public List<Integer> findUserModuleIds(String userId);
	
	public int insertUserModule(@Param("userId") String userId, @Param("menuIds") String[] menuIds);

	@Delete("delete from sys_ur where u_id=#{u_id}")
	public int deleteUserModulesById(String userId);

}
